#include "TcpServer.hpp"
#include "MyInertAddr.hpp"
#include "Socket.hpp"
#include "MyProtocol.hpp"
#include "MyNetCal.hpp"
#include <memory>
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        LOG(LogLevel::FATAL) << "Usage server port";
        exit(USAGE_ERRO);
    }
    // 业务
    std::unique_ptr<NetCal> nc(std::make_unique<NetCal>());
    // 协议

    std::unique_ptr<Protocol> pt(std::make_unique<Protocol>([&](Request &req) -> Response
                                                  { return nc->Execute(req); }));
    // 通信
    std::unique_ptr<TcpServer> ts(std::make_unique<TcpServer>(std::stoi(argv[1]), [&](std::shared_ptr<Socket> sock, InertAddr addr)
                                                    { pt->GetRequest(sock, addr); }));

    return 0;
}